/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.bid.service.plugins  
 */
package com.apache.bid.service.plugins;

import org.apache.log4j.Logger;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.bid.entity.BidItem;
import com.apache.cache.util.Validator;
import com.apache.database.db.IDao;
import com.apache.database.model.MethodParam;

/**
 * description:  查询单个标的
 * @author mhguo 创建时间：2016-4-12  
 * 
 */
public class BidItemEntityPlugin implements PluginConnector {

	private Logger logger = Logger.getLogger(BidItemEntityPlugin.class);
	private IDao bidItemDao;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.zbxsoft.api.manager.PluginConnector#execute(com.zbxsoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo vo) throws Exception {
		ResultEntity result = new ResultEntity();
		try {
			result.setResult("true");
			MethodParam param = new MethodParam("ById", "", "", BidItem.class.getName());
			param.setInfoId(String.valueOf(vo.getParams("itemId")));

			if (!Validator.isNull(String.valueOf(vo.getParams("itemId")))) {
				BidItem item = (BidItem) bidItemDao.selectById(param);
				result.setEntity(item);
				result.setMessage("查询单个BidItem对象成功！");
			} else {
				result.setResult("false");
				result.setMessage("缺少必要的参数，查询单个BidItem对象失败！");
			}
		} catch (Exception e) {
			result.setResult("false");
			logger.error("执行单个BidItem查询失败 ", e);
			result.setMessage("单个BidItem查询失败！");
		}

		return result;
	}

	public void setBidItemDao(IDao bidItemDao) {
		this.bidItemDao = bidItemDao;
	}

}
